//package com.yuxi.guava;
//
//import com.google.common.util.concurrent.RateLimiter;
//
//import java.util.concurrent.ExecutorService;
//import java.util.concurrent.Executors;
//
///**
// * guava 限流
// * Created by yuxi on 17/1/7.
// */
//public class GuavaDemo {
//    private static volatile RateLimiter rateLimiter = RateLimiter.create(80);//每秒可以接受40个请求
//
//    private static ExecutorService executorService = Executors.newFixedThreadPool(60);
//
//
//    public static void test() {
//        if (rateLimiter.tryAcquire()) {//获取成功
//            System.out.println("acquire ...." + Thread.currentThread().getName()+"....."+rateLimiter.getRate()+"......"+rateLimiter.acquire());
//        }
//    }
//
//    public static void main(String[] args) {
//        while (true) {
//            executorService.execute(new Runnable() {
//                @Override
//                public void run() {
//                    test();
//                }
//            });
//        }
//    }
//}
